package org.example.common;

import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@Builder
public class ResponseMessage<T> {

    public static final String CODE_SUCCESS = "200";
    public static final String CODE_AUTH_ERROR = "401";
    public static final String CODE_SYS_ERROR = "500";
    private String code;
    private String message;
    private Object data;

    public ResponseMessage(String code, String message, Object data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static  ResponseMessage success(){
        return ResponseMessage.builder().code(CODE_SUCCESS).message("请求成功").build();
    }

    public static  ResponseMessage success(Object data){
        return new ResponseMessage(CODE_SUCCESS,"请求成功",data);
    }


    public static ResponseMessage error(){
        return new ResponseMessage("500","系统错误！",null);
    }

    public static ResponseMessage error(String message){
        return new ResponseMessage("500", message,null);
    }

    public static ResponseMessage error(String code, String message){
        return new ResponseMessage(code,message,null);
    }

}
